﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Threading;

namespace VB2CS
{
    public sealed class Utils
    {
        public static Array CopyArray(Array arySrc, Array aryDest)
        {
            //for (int i = 0; i < aryDest.Length; ++i) aryDest[i] = arySrc[i];
            //Array.Copy(arySrc, aryDest, arySrc.Length);
            arySrc.CopyTo(aryDest, 0);
            return aryDest;
        }

        internal static bool IsHexOrOctValue(string Value, ref long i64Value)
        {
            int num=0;
            int length = Value.Length;
            while (num < length)
            {
                char ch = Value[num];
                if ((ch == '&') && ((num + 2) < length))
                {
                    ch = char.ToLower(Value[num + 1], CultureInfo.InvariantCulture);
                    //string str = ToHalfwidthNumbers(Value.Substring(num + 2), GetCultureInfo());
                    string str = Value.Substring(num + 2).Trim();
                    switch (ch)
                    {
                        case 'h':
                            i64Value = Convert.ToInt64(str, 0x10);
                            goto Label_0087;

                        case 'o':
                            i64Value = Convert.ToInt64(str, 8);
                            goto Label_0087;
                    }
                    throw new FormatException();
                }
                if ((ch != ' ') && (ch != '　'))
                {
                    return false;
                }
                num++;
            }
            return false;
        Label_0087:
            return true;
        }

        private static CultureInfo GetCultureInfo()
        {
            return Thread.CurrentThread.CurrentCulture;
        }
    }
}
